﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;

namespace Method.SmartMeter
{
    public class HttpRequestExtention
    {
        /// <summary>
        /// 发送http请求信息
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string SendHttpRequest(string url)
        {
            string content = string.Empty;
            try
            {
                using (HttpClient httpClient = new HttpClient())
                {
                    HttpRequestMessage message = new HttpRequestMessage();
                    message.Method = HttpMethod.Get;
                    message.RequestUri = new Uri(url);
                    var reslut = httpClient.SendAsync(message).Result;
                    content = reslut.Content.ReadAsStringAsync().Result;
                }
            }
            catch(Exception ex)
            {

            }
            
            return content;
        }
    }
}
